package mysql

import (
	"gorm.io/gorm"
	"rent-ease/honesrpc/honesrpc"
)

type Hones struct {
	gorm.Model
	Name    string `gorm:"type:varchar(30)"`
	Address string `gorm:"type:varchar(50)"`
	Phone   int    `gorm:"type:int"`
}

func (h *Hones) Honesdetail(db *gorm.DB, id int64) error {
	return db.Debug().Where("id=?", id).First(h).Error
}

func HonesList(db *gorm.DB, list []*honesrpc.HonesList, in *honesrpc.HonesListRequest) ([]*honesrpc.HonesList, error) {
	err2 := db.Debug().
		Scopes(Paginate(int(in.Page), int(in.Size))).
		Find(&list).Error
	return list, err2
}
